bootstrap
Purpose
The bootstrap command is mainly intended to be used by other scripts and enables the ability to bootstrap a Grails application instance outside of the container for usage in tools that require a reference to Grails' ApplicationContext
.
Examples of its usage include Grails' shell and console
Examples
Add this to the top of your Gant script to use this as an include:
includeTargets << grailsScript("_GrailsBootstrap")
Once this is in place you can bootstrap Grails using either of these methods:
loadApp
- Loads and creates theGrailsApplication
instanceconfigureApp
- Loads all plugins and creates the SpringApplicationContext
After running loadApp
the GrailsApplication
instance will be available as the grailsApp
variable:
loadApp()
for (grailsClass in grailsApp.allClasses) { println grailsClass }
After running configureApp
the GrailsPluginManager instance will be available as the pluginManager
variable and the Spring ApplicationContext
instance will be available as the appCtx
variable:
configureApp()
Connection c = appCtx.getBean('dataSource').getConnection()
// do something with connection
Description
Usage:
grails bootstrap